home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / educate / wordy442.zip / TOUPPER.C < prev    next >
C/C++ Source or Header  |  1996-01-28  |  916b  |  53 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define MAXFILENAMELEN 40
  5. #define MAXLEN 60
  6.  
  7. void convert( char *file_name );
  8.  
  9. void main( int argc, char **argv )
  10. {
  11.    char filename [MAXFILENAMELEN];
  12.  
  13.      if( argc != 2 )
  14.         {
  15.         printf( "\n\nFilename to convert to upper case? " );
  16.         gets( filename );
  17.         }
  18.      else
  19.         strcpy( filename, *( argv + 1 ) );
  20.  
  21.      convert( filename ); 
  22. }
  23.  
  24. void convert( char *fname )
  25. {
  26.    char word [MAXLEN];
  27.      
  28.    FILE *fps,
  29.         *fpt;
  30.  
  31.       fps = fopen( fname, "r" );
  32.       fpt = fopen( "tfile", "w" );
  33.  
  34.       while( !feof( fps ) )
  35.          {
  36.          fgets( word, MAXLEN - 1, fps );
  37.  
  38.          if( feof( fps ) ) break;
  39.  
  40.          strupr( word );
  41.          fputs( word, fpt );
  42.  
  43.          }
  44.  
  45.       fclose( fps );
  46.       fclose (fpt );
  47.  
  48.       unlink( fname );
  49.       rename( "tfile", fname );
  50.      
  51.       return;
  52. }
  53.